home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tcoop.arc / TCOOP2.ARC / MOUSETST.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-26  |  1.9 KB  |  63 lines

  1. // mousetst.cpp: This program tests part of the mouse object in text mode 
  2. #include "stdlib.h"
  3. #include "bios.h"
  4. #include "conio.h"
  5. #include "msmouse.h"
  6.  
  7. unsigned E;
  8. int Mx, My;
  9. char Ch;
  10.  
  11. main()
  12. {
  13.   Mouse.Setup(TextScrn);     // Initialize the mouse 
  14.   if (!Mouse.SetupOK()) {    // Mouse intialization failed 
  15.     cprintf("Mouse not detected.\r\n");
  16.     exit(0);
  17.   }
  18.  
  19.   clrscr();      // Setup and draw the screen
  20.   gotoxy(35,12); cprintf("Press here to\r\n");
  21.   gotoxy(35,13); cprintf("quit program\r\n");
  22.   gotoxy(1,21);  cprintf("Current Button Event : No event\r\n");
  23.   gotoxy(1,23);  cprintf("Mouse location (X,Y) : \r\n");
  24.   gotoxy(1,1);   cprintf("Press here to disable mouse     \r\n");
  25.  
  26.   do { // Main interaction loop 
  27.     E = Mouse.Event(Mx, My);
  28.     switch(E) {
  29.       case LMouseDown: 
  30.         gotoxy(23,21); cprintf("LPressed   \r\n"); 
  31.       break;
  32.       case RMouseDown:
  33.         gotoxy(23,21); cprintf("RPressed   \r\n"); 
  34.       break;
  35.       case LMouseStillDown: 
  36.         gotoxy(23,21); cprintf("LStill Down\r\n");
  37.       break;
  38.       case RMouseStillDown: 
  39.         gotoxy(23,21); cprintf("RStill Down\r\n"); 
  40.       break;
  41.       case LMouseUp:
  42.         gotoxy(23,21); cprintf("LMouseUp   \r\n"); 
  43.       break;
  44.       case RMouseUp:
  45.         gotoxy(23,21); cprintf("RMouseUp   \r\n"); 
  46.       break;
  47.     }
  48.     gotoxy(23,23); cprintf("(%d,%d)     \r\n", Mx, My);
  49.     if ((E == LMouseDown) && (Mx >= 0) &&
  50.        (Mx <= 26) && (My == 0)) {
  51.        // Disable mouse until a key is pressed 
  52.        Mouse.TurnOff();
  53.        gotoxy(1,1); cprintf("Press any key to re-enable mouse\r\n");
  54.        bioskey(0);
  55.        gotoxy(1,1); cprintf("Press here to disable mouse     \r\n");
  56.        Mouse.TurnOn();
  57.     }
  58.   } while ((E != MouseDown) || (Mx <= 33) || (Mx >= 47) ||
  59.           (My <= 10) || (My >= 13));
  60.   Mouse.TurnOff(); // Generally, you should turn off the mouse at end
  61. }
  62.  
  63.